80278ab8: 27 bd ff f8  ADDIU sp, sp, 0xfffffff8 (-8)
80278abc: af a0 00 04  SW r0, sp, 0x4 (4)                  [sp + 0x04] = 0;

80278ac0: 24 a5 00 03  ADDIU a1, a1, 0x3 (3)
80278ac4: 24 01 ff fc  ADDIU at, r0, 0xfffffffc (-4)
80278ac8: 00 a1 70 24  AND t6, a1, at
80278acc: 01 c0 28 25  OR a1, t6, r0                                  00000001 11000000 00101000 00100101
80278ad0: 18 a0 00 0f  BLEZ a1, 0x80278b10 (pc + 0x3c)     if ((arg2=(arg2+3 & 0xfffffffc)) <= 0) goto 0x80278b10;
80278ad4: 00 00 00 00  NOP

80278ad8: 8c 8f 00 04  LW t7, a0, 0x4 (4)
80278adc: 8c 99 00 00  LW t9, a0, 0x0 (0)
80278ae0: 01 e5 c0 21  ADDU t8, t7, a1
80278ae4: 03 38 08 2a  SLT at, t9, t8
80278ae8: 14 20 00 09  BNE at, r0, 0x80278b10 (pc + 0x24)  if (arg1->off0x00 < (arg1->off0x04 + arg2)) goto 0x80278b10;
80278aec: 00 00 00 00  NOP

80278af0: 8c 88 00 0c  LW t0, a0, 0xc (12)
80278af4: af a8 00 04  SW t0, sp, 0x4 (4)                  [sp + 0x04] = arg1->off0x0c;

80278af8: 8c 89 00 0c  LW t1, a0, 0xc (12)
80278afc: 01 25 50 21  ADDU t2, t1, a1
80278b00: ac 8a 00 0c  SW t2, a0, 0xc (12)                 arg1->off0x0c += arg2;

80278b04: 8c 8b 00 04  LW t3, a0, 0x4 (4)
80278b08: 01 65 60 21  ADDU t4, t3, a1
80278b0c: ac 8c 00 04  SW t4, a0, 0x4 (4)                  arg1->off0x04 += arg2;

80278b10: 10 00 00 03  BEQ r0, r0, 0x80278b20 (pc + 0xc)
80278b14: 8f a2 00 04  LW v0, sp, 0x4 (4)                  return [sp + 0x04];
80278b18: 10 00 00 01  BEQ r0, r0, 0x80278b20 (pc + 0x4)
80278b1c: 00 00 00 00  NOP
80278b20: 03 e0 00 08  JR ra


[sp + 0x04] = 0;
if ((arg2=(arg2+3 & 0xfffffffc)) <= 0) goto 0x80278b10;
if (arg1->off0x00 < (arg1->off0x04 + arg2)) goto 0x80278b10;
[sp + 0x04] = arg1->off0x0c;
arg1->off0x0c += arg2;
arg1->off0x04 += arg2;
return [sp + 0x04];


#define ROUND_TO_32(s) (((s)+3)&0xfffffffc)

struct allocation_stack {
    u32 maxsize;
    u32 used;
    long unknown1;
    u8 *curr_ptr;
};

void * simple_allocate(struct allocation_stack *as, int size_request)
{
    void *p = 0;
    if ((size_request=ROUND_TO_32(size_request)) > 0 && as->maxsize >= (as->used + size_request)) {
        p = as->curr_ptr;
        as->curr_ptr += size_request;
        as->used += size_request;
    }
    return p;
}
